namespace OpenComposite.EII.Repository
{
	using System;
	using System.Collections.Generic;
	using System.Drawing;
	using System.Text;

	using OpenComposite.Repository.Properties;

	[RepositoryItem(ItemType.LogicalMethodGroup, "logical_method_group", "lm_group_id")]
	public class LogicalMethodGroup : RepositoryItemBaseEx
	{
		#region Initialization

		/// <summary>
		/// Initializes a new instance of the <see cref="LogicalMethodGroup"/> class.
		/// </summary>
		/// <param name="serviceProvider">The service provider.</param>
		/// <param name="bCreateNew">if set to <c>true</c> [b create new].</param>
		public LogicalMethodGroup(IServiceProvider serviceProvider, bool bCreateNew)
			: base("lm_group_id", "lm_group_nm", "lm_group_desc", "lm_group_ntext", Resources.sNewLogicalMethodGroup)
		{
			if ( bCreateNew )
				this.CreateNew();

			InitializeServiceProvider(serviceProvider);
		}

		#endregion Initialization

		#region Public Members

		#region Properties

		/// <summary>
		/// Gets a value indicating whether [allow drop].
		/// </summary>
		/// <value><c>true</c> if [allow drop]; otherwise, <c>false</c>.</value>
		public override bool AllowDrop
		{
			get
			{
				return true;
			}
		}

		/// <summary>
		/// Gets the allowed child types.
		/// </summary>
		/// <value>The allowed child types.</value>
		public override List<ItemType> AllowedChildTypes
		{
			get { return _LISTALLOWED; }
		}

		/// <summary>
		/// Gets the image.
		/// </summary>
		/// <value>The image.</value>
		public override System.Drawing.Image Image
		{
			get { return Resources.png_logical_method; }
		}

		/// <summary>
		/// Gets the image key.
		/// </summary>
		/// <value>The image key.</value>
		public override string ImageKey
		{
			get { return "logical_method_group"; }
		}

		/// <summary>
		/// Gets the type of the repository item.
		/// </summary>
		/// <value>The type of the repository item.</value>
		public override ItemType RepositoryItemType
		{
			get { return ItemType.LogicalMethodGroup; }
		}

		/// <summary>
		/// Gets the repository item type description.
		/// </summary>
		/// <value>The repository item type description.</value>
		public override string RepositoryItemTypeDescription
		{
			get { return ""; }
		}

		/// <summary>
		/// Gets the name of the repository item type.
		/// </summary>
		/// <value>The name of the repository item type.</value>
		public override string RepositoryItemTypeName
		{
			get { return ItemTypes.GetDisplay(this.RepositoryItemType); }
		}

		/// <summary>
		/// Gets the selected image.
		/// </summary>
		/// <value>The selected image.</value>
		public override System.Drawing.Image SelectedImage
		{
			get { return this.Image; }
		}

		/// <summary>
		/// Gets the selected image key.
		/// </summary>
		/// <value>The selected image key.</value>
		public override string SelectedImageKey
		{
			get { return this.ImageKey; }
		}

		/// <summary>
		/// Gets the name of the table.
		/// </summary>
		/// <value>The name of the table.</value>
		public override string TableName
		{
			get { return "logical_method_group"; }
		}

		#endregion Properties

		#region Methods

		/// <summary>
		/// Copies this instance.
		/// </summary>
		/// <param name="deep"><c>true</c> to recursively copy the item and all subitems;
		/// <c>false</c> to copy only the item itself.</param>
		/// <returns>The copied item.</returns>
		public override IRepositoryItem Copy(bool deep)
		{
			LogicalMethodGroup copy = new LogicalMethodGroup(this, true);
			this.CopyDataRowToTarget(copy);
			return copy;
		}

		/// <summary>
		/// Gets the icon.
		/// </summary>
		/// <returns></returns>
		public override System.Drawing.Icon GetIcon()
		{
			return Icon.FromHandle(Resources.png_logical_method.GetHicon());
		}

		#endregion Methods

		#endregion Public Members

		#region Private Members

		#region Constant/Read-Only Fields

		private static readonly List<ItemType> _LISTALLOWED =
			new List<ItemType>(new ItemType[] { ItemType.LogicalWebMethod });

		#endregion Constant/Read-Only Fields

		#endregion Private Members
	}
}